<!DOCTYPE HTML>
<html>
 <head>
  <title></title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.css" />
   <link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap-switch.min.css"/>
   <link rel="stylesheet" type="text/css" href="/static/font-awesome/css/font-awesome.min.css"/>
   <style type="text/css">
   	body{
   		background: #EFF3FC
   	}
   	html, body, .content{
   		height: 100%;
   	}
   	.content {
	    margin-left: 0;
	    margin-top: 0;
	    width: 98%;
	    margin: 0 auto;
	    padding: 0px 20px 0 20px;
    }
    table{
    	width: 90%;
    	margin: 0 auto;
    }
    tr{
    	height: 35px;
    	text-align: center;
    }
    tr:first-child{
    	background: #cccccc;
    	text-align: center;
    }
    tr th{
    	text-align: center;
    }
   
    button, input {
      line-height: normal;
    }
    .archiveChance{
    	height: 90px;
    	background: #FFFFFF;
    	border-radius: 5px;
    	margin-bottom: 17px;
    }
    .archiveChance >div{
    	padding: 10px 31px;
    }
    .archiveChance >div span{
    	padding-right: 20px;
    }
    .archiveClass{
    	height: 78%;
    	background: #FFFFFF;
    	overflow-y: auto;
    }
    .archiveClass >div{
    	padding-top: 20px;
    	padding-bottom: 20px;
        padding-left: 31px;
    }
    .add-btn {
	    border: 2px solid #45CEF6;
	    border-radius: 5px;
	    background-color: #fff;
	}
	.add-box {
	    position: absolute;
	    top: 54%;
	    width: 30px;
	    transform: translate(0,-50%);
	    text-align: center;
	}
	.icon-plus {
	    display: inline-block;
	    height: 100%;
	    vertical-align: middle;
	    font-size: 18px;
	    color: #45CEF6;
	    font-weight: bold;
	}
	.tabList{
		width: 80%;
		margin: 0 auto;
	}
	.pointer{
		cursor: pointer;
	}
   </style>
 </head>
 <body ng-app="logMag" ng-controller="logManageCtrl">
  <div class="content">
    <div style="padding: 10px 0;">系统管理>归档配置</div>
    <div class="archiveChance">
    	<div >
    		<span>默认归档：</span>
    		<div class="switch bootstrap-switch-mini bootstrap-switch-id-switch-size bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-off" data-on="info" data-off="success" style="display:inline-block" >
			    <input type="checkbox" id="mySwitch" checked name="text"/>
			</div>
    	</div>
    	<div>
    		<span>智能归档：</span>
    		<div class="switch bootstrap-switch-mini bootstrap-switch-id-switch-size bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-off " data-on="info" data-off="success" style="display:inline-block">
			    <input type="checkbox" checked name="text"/>
			</div>
    	</div>
    </div>
    <div class="archiveClass">
    	<div class="row">
    		<lable class="col-sm-1">归档分类:</lable>
    		<div class="col-sm-2">
		     	<input type="text" class="form-control" placeholder="输入分类名称，必填"  ng-model="archiveForm.nameClass">
			</div>
			<div class="col-sm-2">
		     	<input type="text" class="form-control" placeholder="输入分类编码，必填" ng-model="archiveForm.codeClass">
			</div>
			<div class="col-sm-2">
		     	<input type="text" class="form-control" placeholder="输入排序" ng-model="archiveForm.sort">
			</div>
			<div class="col-sm-3">
		     	<input type="text" class="form-control" placeholder="输入智能归档关键字，多关键字用逗号隔开" ng-model="archiveForm.keyword">
			</div>
			<div class="col-sm-1" style="height:34px;;">
                <div class="add-box">
                    <button class="add-btn add-box" ng-click="addArchive(archiveForm)">
                        <i class="fa fa-plus icon-plus"></i>
                    </button>
                </div>
            </div>
    	</div>
    	<table class="col-sm-12 table table-striped tabList">
          <tbody>
            <tr ng-repeat="item in dataList">
              <td>{{item.id}}</td>
              <td>{{item.type}}</td>
              <td>{{item.status}}</td>
              <td>{{item.aaa}}</td>
              <td class="pointer">
              	<span title="删除">
              		<a ng-click="deleteArchive()"><i class="fa fa-trash"></i></a>
              	</span>
              	<span title="编辑">
              		<a ng-click="editArchive()"><i class="fa fa fa-pencil "></i></a>
              	</span>
              </td>
            </tr>
          </tbody>
     </table>
   </div>
  </div>
  <!-- 删除用户模态框 -->
  <div class="modal fade" id="delArchiveModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
	            &times;
	        </button>
					<h4 class="modal-title" id="myModalLabel">删除分类</h4>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="col-sm-12">
							删除不可恢复,是否确认删除?
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消
	        </button>
					<button type="button" class="btn btn-primary" ng-click="delArchiveOK(id)">
	            确认
	        </button>
				</div>
			</div>
		</div>
	</div>
	<!--编辑归档分类模态框-->
	<div class="modal fade" id="editArchive" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                &times;
            </button>
					<h4 class="modal-title" id="myModalLabel">
                {{ modalTitle }}
            </h4>
				</div>
				<div class="modal-body">
					<input type="hidden" name="addOrEdit" id="addOrEdit" value="" />
					<div class="row">
						<div class="col-sm-12">
							<form role="form" class="form-horizontal">
								<div class="form-group">
									<label for="firstName" class="col-sm-3 control-label"><span style="color:#ff0000">*</span>分类名称</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" id="firstName" ng-model="archiveForm.nameClass" >
									</div>
								</div>
								<div class="form-group">
									<label for="pwd" class="col-sm-3 control-label"><span style="color:#ff0000">*</span>分类编码</label>
									<div class="col-sm-6">
										<input type="password" class="form-control" id="pwd" ng-model="archiveForm.codeClass" maxlength="30" >
									</div>
								</div>
								<div class="form-group">
									<label for="name" class="col-sm-3 control-label">排序</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" id="name" ng-model="archiveForm.sort">
									</div>
								</div>
								<div class="form-group">
									<label for="department" class="col-sm-3 control-label">归档关键字</label>
									<div class="col-sm-6">
										<input type="text" ng-click="chanceTree()" ng-model="archiveForm.keyword" name="" id="" value="" class="form-control" />
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消
            </button>
					<button type="button" class="btn btn-primary" ng-click="editArchiveOk(userForm)">
                确认
            </button>
				</div>
			</div>
		</div>
	</div>
  <script type="text/javascript" src="/static/assets/js/jquery-3.1.0.js"></script>
   <script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/static/bootstrap/js/bootstrap-switch.min.js"></script>
  <script type="text/javascript" src="/static/assets/js/bui-min.js"></script>
  <script type="text/javascript" src="/static/datepicker/js/datepicker.all.js" ></script>
  <script type="text/javascript" src="/static/plugins/angular/angular.min.js" ></script>
  <script type="application/javascript" src="/static/datepicker/js/moment.min.js"></script>
  <script type="text/javascript" src="/static/assets/js/config-min.js"></script>
  <script type="text/javascript" src="/static/plugins/layui/js/layui.js"></script>
  <script type="text/javascript">
        $('#mySwitch').bootstrapSwitch({
        	onSwitchChange:function(event,state){  
        		console.log("event",event)
		      if(state==true){  
		        alert('已打开');  
		      }else{  
		        alert('已关闭');  
		      }  
		    }  
        });
        $('#mySwitch').bootstrapSwitch('state', true);
   </script>
   <script type="text/javascript">
   	     var app = angular.module('logMag', []);
		    app.controller('logManageCtrl', function ($scope,$http) {
		    	$scope.addArchive=addArchiveFun;//归档分类添加
		    	$scope.deleteArchive=deleteArchiveFun;//删除回档分类
		    	$scope.editArchive=editArchiveFun;//编辑归档分类
		    	$scope.archiveForm={
		    		nameClass:"",
		    		codeClass:"",
		    		sort:"",
		    		keyword:""
		    	};
		    	//获取列表数据
		    	$scope.dataList=function(){
		    		$http.post('/api/orginazation/orglist').then(
						function(resp) {
							$scope.dataList = resp.data.data;
							console.log("3333" + JSON.stringify(resp.data.data))
						},
						function(resp) {
							alert("接口请求失败");
						});
		    	};
		    	$scope.dataList();
		    	
		    	
		    	//模拟假数据
		    	$scope.dataList=[{
		    		"id":"1",
		    		"type":"login",
		    		"status":"登录系统",
		    		"aaa":"登录",
		    		"user":"管理员",
		    		"juese":"admin",
		    		"time":"2019.1.03",
		    		"ip":"1.2.3.3",
		    	},{
		    		"id":"1",
		    		"type":"login",
		    		"status":"登录系统",
		    		"aaa":"登录",
		    		"user":"管理员",
		    		"juese":"admin",
		    		"time":"2019.1.03",
		    		"ip":"1.2.3.3",
		    	},{
		    		"id":"1",
		    		"type":"login",
		    		"status":"登录系统",
		    		"aaa":"登录",
		    		"user":"管理员",
		    		"juese":"admin",
		    		"time":"2019.1.03",
		    		"ip":"1.2.3.3",
		    	}]
		    	
		    //归档分类添加
		    function addArchiveFun(form){
//		    	$http.post('http://127.0.0.1:8000/api/orginazation/orgadd', form).then(
//						function(resp) {
//							console.log("添加成功");
//							$scope.archiveForm={
//					    		nameClass:"",
//					    		codeClass:"",
//					    		sort:"",
//					    		keyword:""
//					    	};
//                      $scope.dataList();
//						},
//						function(resp) {
//							alert("接口请求失败");
//				});
		    }
		    
		    //删除回档分类
		    function deleteArchiveFun(){
				$('#delArchiveModal').modal();
				// 确认删除部门
				$scope.delArchiveOK = function(id) {
					$http({
						method: 'POST',
						url: 'http://127.0.0.1:8000/api/orginazation/orgdelete',
						data: {
							"id": id
						},
					}).then(function successCallback(response) {
						console.log("删除成功");
						// 请求成功执行代码
					}, function errorCallback(response) {
						console.log("删除失败");
						// 请求失败执行代码
					});
					$('#delArchiveModal').modal('hide');
				};
			}
		    //编辑归档分类
		    function editArchiveFun(id){
		    	$scope.modalTitle = "编辑归档分类";
		    	$('#editArchive').modal();
		    	$http({
						method: 'POST',
						url: 'http://127.0.0.1:8000/api/orginazation/orgdelete',
						data: {
							"id": id
						},
					}).then(function successCallback(response) {
						console.log("删除成功");
						// 请求成功执行代码
					}, function errorCallback(response) {
						console.log("删除失败");
						// 请求失败执行代码
					});
		    };
		    
		    //编辑确认
		    $scope.editArchiveOk=function(form){
		    	$('#editArchive').modal("hide");
		    	$http.post('http://127.0.0.1:8000/api/orginazation/orgadd', form).then(
						function(resp) {
							console.log("添加成功");
							$scope.archiveForm={
					    		nameClass:"",
					    		codeClass:"",
					    		sort:"",
					    		keyword:""
					    	};
                        $scope.dataList();
						},
						function(resp) {
							alert("接口请求失败");
				});
		    }
		})
   </script> 
</body>
</html>  